#include <stdio.h>
#define IS_WHITE_SPACE(c) (c == '\n' || c == '\t' || c == ' ')
int main(int argc,char *argv[])
{
	if(argc < 2)
	{
		printf("parameter error\n");
		return 1;
	}
	FILE *p = fopen(argv[1],"r");
	if(p == NULL)
	{
		printf("fail to open file\n");
		return 1;
	}
	char c = fgetc(p);
	int letter_count = 0,line_count = 0,word_count = 0;
	while(c != EOF)
	{
		if(c == '\n') line_count++;
		if(IS_WHITE_SPACE(c)) word_count++;
		letter_count++;
		c = fgetc(p);
	}
	printf("letter_count = %d\n",letter_count);
	printf("line_count = %d\n",line_count);
	printf("word_count = %d\n",word_count);
	return 0;
}
